{/* LAYOUT模板 */}
	<layout name="layout"/>
{/* LAYOUT模板 */}
{/* import Js,Css */}
	<js href="__PUBLIC__/js/admin/listTable.js"/>
	<js href="__PUBLIC__/js/admin/js.util.js"/>
	<css href="__PUBLIC__/css/admin/common.css"/>
	<js href="__PUBLIC__/js/admin/js.selectzone.js"/>
	
	<css href="__PUBLIC__/css/jquery-ui.css" />
	<js href="__PUBLIC__/js/core/jquery-ui.1.10.4.js" />
	<js href="__PUBLIC__/js/core/plugins.js"/>
{/* import js,css */}
<!-- [position] -->
	<include file="Template:position"/>
<!-- [position] -->

<div class="main-div">
	<form action="__URL__/{$action}" method="post" name="theForm" enctype="multipart/form-data" onsubmit="return validate()">
		<table width="100%">
			<tr>
				<td class="label" align="right">类型名称</td>
				<td>
				<input type='text' name='type_name' maxlength="30" value="{$bonus_arr.type_name}" size='20' />    </td>
			</tr>
			<tr>
				<td class="label" align="right">
					<a href="javascript:showNotice('Type_money_a');" title="{$lang.form_notice}">
						<img src="__PUBLIC__/image/admin/notice.gif" width="16" height="16" border="0" alt="{$lang.form_notice}">
					</a>
					红包金额
				</td>
				<td>
				<input type="text" name="type_money" value="{$bonus_arr.type_money}" size="20" />
					<br/>
					<span class="notice-span" <if condition="$help_open">style="display:block"<else/>style="display:none"</if> id="Type_money_a">
						此类型的红包可以抵销的金额
					</span>   
				</td>
			</tr>
			<tr>
				<td class="label" align="right">
					<a href="javascript:showNotice('NoticeMinGoodsAmount');" title="{$lang.form_notice}">
						<img src="__PUBLIC__/image/admin/notice.gif" width="16" height="16" border="0" alt="{$lang.form_notice}" />
					</a>
					最小订单金额
				</td>
				<td>
					<input name="min_goods_amount" type="text" id="min_goods_amount" value="{$bonus_arr.min_goods_amount}" size="20" />
					<br/>
					<span class="notice-span" <if condition="$help_open">style="display:block"<else/>style="display:none"</if> id="NoticeMinGoodsAmount">
						只有商品总金额达到这个数的订单才能使用这种红包
					</span> 
				</td>
			</tr>
			<tr>
				<td class="label" align="right">如何发放此类型红包</td>
				<td>
					<input type="radio" name="send_type" value="0" <if condition="$bonus_arr['send_type'] eq 0">checked="true"</if> onClick="showunit(0)"  />{$lang_send_by[0]}
					<input type="radio" name="send_type" value="1" <if condition="$bonus_arr['send_type'] eq 1">checked="true"</if> onClick="showunit(1)"  />{$lang_send_by[1]}
					<input type="radio" name="send_type" value="2" <if condition="$bonus_arr['send_type'] eq 2">checked="true"</if> onClick="showunit(2)"  />{$lang_send_by[2]}
					<input type="radio" name="send_type" value="3" <if condition="$bonus_arr['send_type'] eq 3">checked="true"</if> onClick="showunit(3)"  />{$lang_send_by[3]}    
				</td>
			</tr>
			<tr id="1" style="">
				<td class="label" align="right">
					<a href="javascript:showNotice('Order_money_a');" title="{$lang.form_notice}">
					<img src="__PUBLIC__/image/admin/notice.gif" width="16" height="16" border="0" alt="{$lang.form_notice}"></a>订单下限
				</td>
				<td>
					<input name="min_amount" type="text" id="min_amount" value="{$bonus_arr.min_amount}" size="20" />
					<br/>
					<span class="notice-span" <if condition="$help_open">style="display:block"<else/>style="display:none"</if> id="Order_money_a">
						只要订单金额达到该数值，就会发放红包给用户
					</span>    
				</td>
			</tr>
			<tr>
				<td class="label" align="right">
					<a href="javascript:showNotice('Send_start_a');" title="{$lang.form_notice}">
						<img src="__PUBLIC__/image/admin/notice.gif" width="16" height="16" border="0" alt="{$lang.form_notice}">
					</a>
					发放起始日期
				</td>
				<td>
					<input name="send_start_date" type="text" id="send_start_date" size="22" value='{$bonus_arr.send_start_date}' readonly="readonly" />
					<br/>
					<span class="notice-span" <if condition="$help_open">style="display:block"<else/>style="display:none"</if> id="Send_start_a">
						只有当前时间介于起始日期和截止日期之间时，此类型的红包才可以发放
					</span>    
				</td>
			</tr>
			<tr>
				<td class="label" align="right">发放结束日期</td>
				<td>
					<input name="send_end_date" type="text" id="send_end_date" size="22" value='{$bonus_arr.send_end_date}' readonly="readonly" />  
				</td>
			</tr>
			<tr>
				<td class="label" align="right">
					<a href="javascript:showNotice('Use_start_a');" title="{$lang.form_notice}">
					<img src="__PUBLIC__/image/admin/notice.gif" width="16" height="16" border="0" alt="{$lang.form_notice}"></a>
					使用起始日期
				</td>
				<td>
					<input name="use_start_date" type="text" id="use_start_date" size="22" value='{$bonus_arr.use_start_date}' readonly="readonly" />
					<input name="selbtn3" type="button" id="selbtn3" onclick="return showCalendar('use_start_date', '%Y-%m-%d', false, false, 'selbtn3');" value="选择"/>
					<br/>
					<span class="notice-span" <if condition="$help_open">style="display:block"<else/>style="display:none"</if> id="Use_start_a">
						只有当前时间介于起始日期和截止日期之间时，此类型的红包才可以使用
					</span>    
				</td>
			</tr>
			<tr>
				<td class="label" align="right">使用结束日期</td>
				<td>
					<input name="use_end_date" type="text" id="use_end_date" size="22" value='{$bonus_arr.use_end_date}' readonly="readonly" />
					<input name="selbtn4" type="button" id="selbtn4" onclick="return showCalendar('use_end_date', '%Y-%m-%d', false, false, 'selbtn4');" value="选择"/>    
				</td>
			</tr>
			<tr>
				<td class="label">&nbsp;</td>
				<td>
				<input type="submit" value="确定" />
				<input type="reset" value="重置" />
				<input type="hidden" name="act" value="{$form_act}" />
				<input type="hidden" name="type_id" value="{$bonus_arr.type_id}" />    </td>
			</tr>
		</table>
	</form>
</div>



<script>	
	$(function() {
		$( "#send_start_date" ).datepicker({dateFormat: 'yy-mm-dd'});
		$( "#send_end_date" ).datepicker({dateFormat: 'yy-mm-dd'});
		$( "#use_start_date" ).datepicker({dateFormat: 'yy-mm-dd'});
		$( "#use_end_date" ).datepicker({dateFormat: 'yy-mm-dd'});
	});	
</script>



<script language="javascript">

	document.forms['theForm'].elements['type_name'].focus();
	/**
	* 检查表单输入的数据
	*/
	function validate(){
		validator = new Validator("theForm");
		validator.required("type_name",      type_name_empty);
		validator.required("type_money",     type_money_empty);
		validator.isNumber("type_money",     type_money_isnumber, true);
		validator.islt('send_start_date', 'send_end_date', send_start_lt_end);
		validator.islt('use_start_date', 'use_end_date', use_start_lt_end);
		if (document.getElementById(1).style.display == ""){
			var minAmount = parseFloat(document.forms['theForm'].elements['min_amount'].value);
			if (isNaN(minAmount) || minAmount <= 0)
			{
			validator.addErrorMsg(invalid_min_amount);
			}	
		}
		return validator.passed();
	}

	/* 红包类型按订单金额发放时才填写 */
	function gObj(obj){
		var theObj;
		if (document.getElementById){
			if (typeof obj=="string"){
				return document.getElementById(obj);
			} else {
				return obj.style;
			}
		}
		return null;
	}

	function showunit(get_value){
		gObj("1").style.display =  (get_value == 2) ? "" : "none";
		document.forms['theForm'].elements['selbtn1'].disabled  = (get_value != 1 && get_value != 2);
		document.forms['theForm'].elements['selbtn2'].disabled  = (get_value != 1 && get_value != 2);
		return;
	}
</script>



